﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace SignetKA
{
    public class MyApplicationContext : ApplicationContext
    {
        public MyApplicationContext(Form mainForm) : base(mainForm)
        {
            mainForm.FormClosed += MainFormClosed;
        }

        private void MainFormClosed(object sender, FormClosedEventArgs e)
        {
            //窗口关闭 ，选择策略
            if (MainForm is StartupForm f_startup)
            {
                if (string.IsNullOrEmpty(f_startup.SignetPath) || string.IsNullOrEmpty(f_startup.Pwd))
                    return;

                Form newForm = new Form1(f_startup.Pwd, f_startup.SignetPath);
                newForm.FormClosed += (s, args) => ExitThread(); // 新窗体关闭时退出应用
                MainForm = newForm;
                newForm.Show();
            }
        }
    }
}
